package com.borqs.music.tasks;

import java.util.HashMap;

import org.json.JSONObject;

import com.borqs.music.executor.Task;
import com.borqs.music.executor.TaskListener;
import com.borqs.music.http.HttpRequest;
import com.borqs.music.http.HttpResponse;
import com.borqs.music.http.RequestMethod;
import com.borqs.music.util.MusicConf;

public class UploadStatisticsTask extends Task {
    private String mStatisticsJson;
    private String ticket;

    public UploadStatisticsTask(TaskListener listener, String statisticsJson, String ticket) {
        super(listener);
        this.ticket = ticket;
        mStatisticsJson = statisticsJson;
    }

    @Override
    public Object handleResponse(HttpResponse resp) throws Exception {
        checkResponse(resp);
        JSONObject obj = resp.asJSONObject();
        return obj.get("result");
    }

    @Override
    public HttpRequest prepareRequest() {
        HashMap<String, String> params = new HashMap<String, String>();
        params.put("content", mStatisticsJson);
        final String URL = MusicConf.getUrl(MusicConf.ReqType.MUSIC_UPLOAD_STATISTICS);
        HttpRequest request = new HttpRequest(RequestMethod.POST, URL, ticket, params);
        return request;
    }

   

}
